package com.xbongbong.paas.help;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.PaasFormEntity;
import com.xbongbong.paas.enums.PlatFormEnum;
import com.xbongbong.paas.model.CloudCodeControlModel;
import com.xbongbong.paas.model.CloudCodePermissionModel;
import com.xbongbong.paas.model.PaasFormModel;
import com.xbongbong.paas.pojo.ButtonPojo;
import com.xbongbong.paas.pojo.DetailTabPojo;
import com.xbongbong.sys.pojo.DynamicPermissionPojo;
import com.xbongbong.sys.pojo.DynamicPermissionSubPojo;
import com.xbongbong.paas.pojo.PermissionComplexTermPojo;
import com.xbongbong.paas.pojo.vo.PaasFormDataEsListVO;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.pro.detailtab.pojo.TabConfigPojo;
import com.xbongbong.pro.domain.entity.CloudCodeControlEntity;
import com.xbongbong.pro.domain.entity.CloudCodePermissionEntity;
import com.xbongbong.pro.domain.entity.DetailTabConfigEntity;
import com.xbongbong.pro.enums.cloudcode.enums.CloudCodeAppPermissinlEnum;
import com.xbongbong.pro.enums.cloudcode.enums.CloudCodeControlEnum;
import com.xbongbong.pro.form.pojo.TopPermissionsPoJo;
import com.xbongbong.pro.menu.pojo.vo.AppMenuListVO;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.sys.help.SysCloudCodeHelp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * 云叩
 * 创建时间 2020/9/21 8:57 PM
 * 修改时间 2020/9/21 8:57 PM
 * @author chy
 */
@Component
public class CloudCodeHelp {
    private static final Logger LOG = LoggerFactory.getLogger(CloudCodeHelp.class);
    @Resource
    private CloudCodeControlModel cloudCodeControlModel;
    @Resource
    private CloudCodePermissionModel cloudCodePermissionModel;
    @Resource
    private PaasFormModel paasFormModel;
    @Resource
    private SysCloudCodeHelp sysCloudCodeHelp;

    /**
     * 设置云叩控件的列表按钮(web)
     * @param corpid
     * @param dynamicPermSet userVo中的动态权限alias集合
     * @param appId
     * @param formId
     * @param businessType
     * @param formDataListVO
     * 创建时间 2020/9/28 7:21 PM
     * 修改时间 2020/9/28 7:21 PM
     * @author chy
     */
    public void setCloudCodeListButton(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                       PaasFormDataEsListVO formDataListVO) {

        if (Objects.isNull(dynamicPermSet)) {
            return;
        }

        if (Objects.nonNull(businessType) && businessType > 0) {
            appId = null;
            formId = null;
        }
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, PlatFormEnum.WEB,
                appId, formId, businessType, CloudCodeControlEnum.BUTTON_LIST.getCode());
        if (cloudCodeControls.isEmpty()) {
            return;
        }
        List<ButtonPojo> buttons = formDataListVO.getBottomPermissions();
        buttons = buttons == null ? new ArrayList<>() : buttons;
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (dynamicPermSet.contains(alias)) {
                ButtonPojo buttonPojo = new ButtonPojo();
                buttonPojo.setIcon("icon-18");
                buttonPojo.setAttr(alias);
                buttonPojo.setValue(cloudCodeControl.getName());
                buttonPojo.setActions(cloudCodeControl.getActions());
                buttons.add(buttonPojo);
            }
        }
    }
    /**
     * 设置云叩控件的详情按钮(web)
     * @param corpid
     * @param dynamicPermSet
     * @param appId
     * @param formId
     * @param businessType
     * @param buttonPojoList
     * 创建时间 2020/9/21 9:01 PM
     * 修改时间 2020/9/21 9:01 PM
     * @author chy
     */
    public void setCloudCodeDetailButton(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                             List<ButtonPojo> buttonPojoList, String platForm) {
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, PlatFormEnum.getByValue(platForm),
                appId, formId, businessType, CloudCodeControlEnum.BUTTON_DETAIL.getCode());
        if (cloudCodeControls.isEmpty()) {
            return;
        }
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (Objects.nonNull(dynamicPermSet) && dynamicPermSet.contains(alias)) {
                ButtonPojo buttonPojo = new ButtonPojo();
                buttonPojo.setButtonId(alias);
                buttonPojo.setIcon("icon-18");
                buttonPojo.setValue(cloudCodeControl.getName());
                buttonPojo.setAttr(alias);
                buttonPojo.setActions(cloudCodeControl.getActions());
                buttonPojoList.add(buttonPojo);
            }
        }
    }
    /**
     * 设置云叩控件的详情按钮(web)
     * @param corpid
     * @param dynamicPermSet
     * @param appId
     * @param formId
     * @param businessType
     * @param buttonPojoList
     * 创建时间 2020/9/21 9:01 PM
     * 修改时间 2020/9/21 9:01 PM
     * @author chy
     */
    public void setCloudCodeDetailButton4Web(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                             List<ButtonPojo> buttonPojoList) {
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, PlatFormEnum.WEB,
                appId, formId, businessType, CloudCodeControlEnum.BUTTON_DETAIL.getCode());
        if (cloudCodeControls.isEmpty()) {
            return;
        }
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (Objects.nonNull(dynamicPermSet) && dynamicPermSet.contains(alias)) {
                ButtonPojo buttonPojo = new ButtonPojo();
                buttonPojo.setIcon("icon-18");
                buttonPojo.setAttr(alias);
                buttonPojo.setValue(cloudCodeControl.getName());
                buttonPojo.setActions(cloudCodeControl.getActions());
                buttonPojoList.add(buttonPojo);
            }
        }
    }

    /**
     * 云叩移动端详情按钮添加
     * @param corpid
     * @param dynamicPermSet
     * @param appId
     * @param formId
     * @param businessType
     * @param topPermissions
     * 创建时间 2020/9/28 7:36 PM
     * 修改时间 2020/9/28 7:36 PM
     * @author chy
     */
    public void setCloudCodeDetailButton4Dingtalk(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                                  List<TopPermissionsPoJo> topPermissions) {
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, PlatFormEnum.DINGTALK,
                appId, formId, businessType, CloudCodeControlEnum.BUTTON_DETAIL.getCode());
        if (cloudCodeControls.isEmpty()) {
            return;
        }
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (Objects.nonNull(dynamicPermSet) && dynamicPermSet.contains(alias)) {
                TopPermissionsPoJo buttonPojo = new TopPermissionsPoJo();
                buttonPojo.setAttr(alias);
                buttonPojo.setBtnType(alias);
                buttonPojo.setIcon("icon-18");
                buttonPojo.setValue(cloudCodeControl.getName());
                buttonPojo.setActions(cloudCodeControl.getActions());
                topPermissions.add(buttonPojo);
            }
        }
    }

    /**
     * 设置云叩相关tab设置，用户回显
     * @param corpid
     * @param dynamicPermSet
     * @param appId
     * @param formId
     * @param businessType
     * @param tabConfigEntity
     * @param tabConfigs
     */
    public void setCloudCodeTabConfig(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                      DetailTabConfigEntity tabConfigEntity, List<TabConfigPojo> tabConfigs) {
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, null, appId, formId,
                businessType, CloudCodeControlEnum.TAB.getCode());
        if (cloudCodeControls.isEmpty()) {
            return;
        }
        //已设置的tab
        List<TabConfigPojo> tabConfigPojos = null;
        try {
            tabConfigPojos = JSONArray.parseArray(tabConfigEntity.getTabConfig(), TabConfigPojo.class);
        } catch (Exception e) {
            tabConfigPojos = new ArrayList<>();
        }
        Map<String, TabConfigPojo> configPojoMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        tabConfigPojos.forEach(configPojo -> configPojoMap.put(configPojo.getAttr(), configPojo));
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (Objects.nonNull(dynamicPermSet) && dynamicPermSet.contains(alias)) {
                TabConfigPojo tabConfigPojo = null;
                if (!configPojoMap.containsKey(alias)) {
                    tabConfigPojo = new TabConfigPojo();
                    tabConfigPojo.setEnable(1);
                    tabConfigPojo.setAttr(alias);
                    tabConfigPojo.setKey(alias);
                    tabConfigPojo.setSort(0);
                } else {
                    tabConfigPojo = configPojoMap.get(alias);
                }
                tabConfigPojo.setName(cloudCodeControl.getName());
                tabConfigs.add(tabConfigPojo);
            }
        }
    }

    /**
     * 追加云叩tab（web）
     * @param corpid
     * @param dynamicPermSet
     * @param appId
     * @param formId
     * @param businessType
     * @param tabPojoList
     * 创建时间 2020/9/23 10:56 AM
     * 修改时间 2020/9/23 10:56 AM
     * @author chy
     */
    public void setCloudCodeTab4Web(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                    List<DetailTabPojo> tabPojoList) {
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, PlatFormEnum.WEB, appId, formId,
                businessType, CloudCodeControlEnum.TAB.getCode());
        Set<String> keySet = new HashSet<>();
        for (DetailTabPojo tabPojo : tabPojoList) {
            keySet.add(tabPojo.getAttr());
        }
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (Objects.nonNull(dynamicPermSet) && dynamicPermSet.contains(alias)) {
                if (keySet.contains(alias)) {
                    continue;
                }
                DetailTabPojo detailTabPojo = new DetailTabPojo();
                detailTabPojo.setAttr(alias);
                detailTabPojo.setName(cloudCodeControl.getName());
                detailTabPojo.setKey(alias);
                detailTabPojo.setActions(cloudCodeControl.getActions());
                tabPojoList.add(detailTabPojo);
            }
        }
    }


    /**
     * 追加云叩tab（dingtalk）
     * @param corpid
     * @param dynamicPermSet
     * @param appId
     * @param formId
     * @param businessType
     * @param tabPojoList
     * 创建时间 2020/9/23 10:56 AM
     * 修改时间 2020/9/23 10:56 AM
     * @author chy
     */
    public void setCloudCodeTab4Dingtalk(String corpid, Set<String> dynamicPermSet, Long appId, Long formId, Integer businessType,
                                         List<DetailTabPojo> tabPojoList) {

        if (Objects.isNull(dynamicPermSet)) {
            return;
        }
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.getByType(corpid, PlatFormEnum.DINGTALK, appId, formId,
                businessType, CloudCodeControlEnum.TAB.getCode());
        Set<String> keySet = new HashSet<>();
        for (DetailTabPojo tabPojo : tabPojoList) {
            keySet.add(tabPojo.getAttr());
        }
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            String alias = getCloudCodeAlias(cloudCodeControl.getId());
            if (dynamicPermSet.contains(alias)) {
                if (keySet.contains(alias)) {
                    continue;
                }
                DetailTabPojo detailTabPojo = new DetailTabPojo();
                detailTabPojo.setAttr(alias);
                detailTabPojo.setName(cloudCodeControl.getName());
                detailTabPojo.setKey(alias);
                detailTabPojo.setActions(cloudCodeControl.getActions());
                tabPojoList.add(detailTabPojo);
            }
        }
    }

    /**
     * 添加云叩权限(paas)
     * @param corpid
     * @param appId
     * @param menuId
     * @param modulePerms
     * 创建时间 2020/9/23 7:38 PM
     * 修改时间 2020/9/23 7:38 PM
     * @author chy
     */
    public void addCloudCodePermission(String corpid, Long appId, Long menuId, List<PermissionComplexTermPojo> modulePerms) {
        //获取appId、menuId下的所有表单
        Map<String, Object> param = new HashMap<>();
        param.put("corpid", corpid);
        param.put("appId", appId);
        param.put("menuId", menuId);
        param.put("del", BasicConstant.ZERO);
        List<PaasFormEntity> paasForms = paasFormModel.findEntity(param);
        List<Long> formIdIn = new ArrayList<>();
        for (PaasFormEntity paasForm : paasForms) {
            formIdIn.add(paasForm.getId());
        }
        param.clear();
        param.put("corpid", corpid);
        param.put("appId", appId);
        param.put("formIdIn", formIdIn);
        param.put("enable", BasicConstant.ONE);
        param.put("del", BasicConstant.ZERO);
        List<CloudCodePermissionEntity> cloudCodePermissions = cloudCodePermissionModel.findEntities(param);
        for (CloudCodePermissionEntity cloudCodePermission : cloudCodePermissions) {
            PermissionComplexTermPojo permissionComplexTermPojo = new PermissionComplexTermPojo();
            permissionComplexTermPojo.setAlias(cloudCodePermission.getAlias());
            permissionComplexTermPojo.setName(cloudCodePermission.getName());
            permissionComplexTermPojo.setProPermissionId(cloudCodePermission.getId().intValue());
            permissionComplexTermPojo.setValue(BasicConstant.ZERO);
            permissionComplexTermPojo.setAlias(cloudCodePermission.getAlias());
            modulePerms.add(permissionComplexTermPojo);
        }
    }

    /**
     * 添加云叩权限(saas)
     * @param corpid
     * @param alias
     * @param modulePerms
     * 创建时间 2020/9/23 7:38 PM
     * 修改时间 2020/9/23 7:38 PM
     * @author chy
     */
    public void addCloudCodePermission(String corpid, String alias, List<PermissionComplexTermPojo> modulePerms) {

        CloudCodeAppPermissinlEnum cloudCodeAppPermissinlEnum = CloudCodeAppPermissinlEnum.getByAlias(alias);
        if (Objects.equals(cloudCodeAppPermissinlEnum, CloudCodeAppPermissinlEnum.UNKNOWN)) {
            return;
        }
        //获取appId、menuId下的所有表单
        Map<String, Object> param = new HashMap<>();
        param.put("corpid", corpid);
        param.put("businessType", cloudCodeAppPermissinlEnum.getCode());
        param.put("enable", BasicConstant.ONE);
        param.put("del", BasicConstant.ZERO);
        List<CloudCodePermissionEntity> cloudCodePermissions = cloudCodePermissionModel.findEntities(param);
        for (CloudCodePermissionEntity cloudCodePermission : cloudCodePermissions) {
            PermissionComplexTermPojo permissionComplexTermPojo = new PermissionComplexTermPojo();
            permissionComplexTermPojo.setAlias(cloudCodePermission.getAlias());
            permissionComplexTermPojo.setName(cloudCodePermission.getName());
            permissionComplexTermPojo.setProPermissionId(cloudCodePermission.getId().intValue());
            permissionComplexTermPojo.setValue(BasicConstant.ZERO);
            modulePerms.add(permissionComplexTermPojo);
        }
    }

    /**
     * 拼接云叩相关alias
     * @param cloudCodeControlId
     * @return
     */
    public String getCloudCodeAlias(Long cloudCodeControlId) {
        return PaasConstant.CLOUD_CODE_ALIAS + "_" + cloudCodeControlId;
    }

    /**
     * 判断是否云叩的alias
     * @param alias
     * @return
     */
    public Boolean isCloudCodeAlias(String alias) {
        if (StringUtil.isEmpty(alias)) {
            return false;
        }
        return  alias.indexOf(PaasConstant.CLOUD_CODE_ALIAS) > -1;
    }

    /**
     * 获取动态权限的alias集合
     * @param dynamicPermissions
     * @return
     * 创建时间 2020/9/27 5:18 PM
     * 修改时间 2020/9/27 5:18 PM
     * @author chy
     */
    public Set<String> getDynamicPermissionSet(String dynamicPermissions) {
        return SysCloudCodeHelp.getDynamicPermissionSet(dynamicPermissions);
    }

    /**
     * 获取businessType下所有的云叩权限alias
     * @param corpid
     * @param businessType
     * @return
     * 创建时间 2020/9/28 2:39 PM
     * 修改时间 2020/9/28 2:39 PM
     * @author chy
     */
    public Set<String> getAliasSetByBusinessType(String corpid, Integer businessType) {
        Map<String, Object> param = new HashMap<>();
        param.put("corpid", corpid);
        param.put("businessType", businessType);
        param.put("del", BasicConstant.ZERO);
        List<CloudCodePermissionEntity> cloudCodePermissions = cloudCodePermissionModel.findEntities(param);
        Set<String> aliasSet = new HashSet<>();
        for (CloudCodePermissionEntity cloudCodePermission : cloudCodePermissions) {
            aliasSet.add(cloudCodePermission.getAlias());
        }
        return aliasSet;
    }

    public Set<String> getAliasSetByFormId(String corpid, Long formId) {
        Map<String, Object> param = new HashMap<>();
        param.put("corpid", corpid);
        param.put("formId", formId);
        param.put("del", BasicConstant.ZERO);
        List<CloudCodePermissionEntity> cloudCodePermissions = cloudCodePermissionModel.findEntities(param);
        Set<String> aliasSet = new HashSet<>();
        for (CloudCodePermissionEntity cloudCodePermission : cloudCodePermissions) {
            aliasSet.add(cloudCodePermission.getAlias());
        }
        return aliasSet;
    }

    public Set<String> getCompanyDynamicPermissionSet(String corpid) {
        return sysCloudCodeHelp.getCompanyDynamicPermissionSet(corpid);
    }


    //递归获取Alias含中有的cloudCode值的List
    public void getCloudCodeAlias(List<Long> cloudCodeControlIdIn, List<AppMenuListVO> paasMenuEntityList){

        Iterator<AppMenuListVO> iterator = paasMenuEntityList.iterator();
        while (iterator.hasNext()){
            AppMenuListVO appMenuListVO = iterator.next();
            if (!appMenuListVO.getSubMenuList().isEmpty()){
                getCloudCodeAlias(cloudCodeControlIdIn, appMenuListVO.getSubMenuList());
            }
            if (isCloudCodeAlias(appMenuListVO.getAlias())) {
                String alias = appMenuListVO.getAlias();
                String cloudCodeControlIdStr = alias.substring(alias.indexOf("_") + 1);
                Long cloudCodeControlId = StringUtil.StringToLong(cloudCodeControlIdStr, 0L);
                cloudCodeControlIdIn.add(cloudCodeControlId);
            }
        }
    }

    /**
     * 过滤平台不对应的菜单、添加actions
     * @param corpid
     * @param platform
     * @param paasMenuEntityList
     */
    public void setMenuActions(String corpid, String platform, List<AppMenuListVO> paasMenuEntityList) {
        List<Long> cloudCodeControlIdIn = new ArrayList<>();
        //通过alias获取cloudCodeControlId
//        for (AppMenuListVO paasMenu : paasMenuEntityList) {
//            if (isCloudCodeAlias(paasMenu.getAlias())) {
//                String alias = paasMenu.getAlias();
//                String cloudCodeControlIdStr = alias.substring(alias.indexOf("_") + 1);
//                Long cloudCodeControlId = StringUtil.StringToLong(cloudCodeControlIdStr, 0L);
//                cloudCodeControlIdIn.add(cloudCodeControlId);
//            }
//            getCloudCodeAlias(cloudCodeControlIdIn, paasMenu);
//        }
        getCloudCodeAlias(cloudCodeControlIdIn, paasMenuEntityList);

        List<String> platformIn = new ArrayList<>();
        platformIn.add(PlatFormEnum.ALL.getValue());
        platformIn.add(platform);

        Map<String, Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid", corpid);
        param.put("idIn", cloudCodeControlIdIn);
        param.put("platformIn", platformIn);
        param.put("del", BasicConstant.ZERO);
        //对应平台的所有控件
        List<CloudCodeControlEntity> cloudCodeControls = cloudCodeControlModel.findEntities(param);
        Map<String, CloudCodeControlEntity> cloudCodeControlMap = new HashMap<>();
        for (CloudCodeControlEntity cloudCodeControl : cloudCodeControls) {
            cloudCodeControlMap.put(getCloudCodeAlias(cloudCodeControl.getId()), cloudCodeControl);
        }

        Iterator<AppMenuListVO> paasMenuIterator = paasMenuEntityList.iterator();

        while (paasMenuIterator.hasNext()) {
            AppMenuListVO paasMenu = paasMenuIterator.next();

            //二级菜单填入低代码的Actions
            if (!paasMenu.getSubMenuList().isEmpty()) {
                Iterator<AppMenuListVO> subMenuIterator = paasMenu.getSubMenuList().iterator();
                while (subMenuIterator.hasNext()) {
                    AppMenuListVO subMenu = subMenuIterator.next();
                    if (isCloudCodeAlias(subMenu.getAlias())) {
                        CloudCodeControlEntity cloudCodeControl = cloudCodeControlMap.get(subMenu.getAlias());
                        if (Objects.nonNull(cloudCodeControl)) {
                            subMenu.setActions(cloudCodeControl.getActions());
                            subMenu.setIcon("icon-18");
                        } else {
                            subMenuIterator.remove();
                        }
                    }
                }
            }

            if (isCloudCodeAlias(paasMenu.getAlias())) {
                CloudCodeControlEntity cloudCodeControl = cloudCodeControlMap.get(paasMenu.getAlias());
                if (Objects.nonNull(cloudCodeControl)) {
                    paasMenu.setActions(cloudCodeControl.getActions());
                    paasMenu.setIcon("icon-18");
                } else {
                    paasMenuIterator.remove();
                }
            }
        }
    }


    /**
     * alias是否在云叩权限中
     * @param alias
     * @param dynamicPermissions
     * @return
     */
    public boolean hasCloudCodePermissions(String alias, String dynamicPermissions) {
        List<DynamicPermissionPojo> dynamicPermissionPojos = JSON.parseArray(dynamicPermissions, DynamicPermissionPojo.class);
        Set<String> aliasSet = new HashSet<>();
        if (CollectionsUtil.isEmpty(dynamicPermissionPojos)) {
            return false;
        }
        for (DynamicPermissionPojo dynamicPermissionPojo : dynamicPermissionPojos) {
            List<DynamicPermissionSubPojo> modules = dynamicPermissionPojo.getModules();
            for ( DynamicPermissionSubPojo dynamicPermissionSubPojo : modules ) {
                aliasSet.add(dynamicPermissionSubPojo.getAlias());
            }
        }
        if (aliasSet.contains(alias)) {
            return true;
        }
        return false;
    }
}
